// 正则-match方法使用

#include <regex>
#include <iostream>
#include "time.h"

int main(void)
{
    std::string projname_ = "UseSqlite3";
    std::string fullpath = "";

    const std::string NAME_SUFFIX = "sqlites";
    // std::string db_file = "xx13.db";
    // std::string db_file = "a/xx13.db";
    // std::string db_file = "a/b/xx13.db";
    std::string db_file = "sqlites/xx13.db";
    std::regex only_name_reg("^\\w+\\.db$");
    std::regex path_name_reg("^(\\w+/)+\\w+\\.db$");
    std::regex spe_name_reg("^(" + NAME_SUFFIX + "/)*\\w+\\.db$");

    if (std::regex_match(db_file, only_name_reg))
    {
        std::cout << "db_file(" << db_file << ") is only name" << std::endl;
        fullpath += projname_ + "_" + NAME_SUFFIX + "/" + db_file;
    }
    else if (std::regex_match(db_file, path_name_reg))
    {
        std::cout << "db_file(" << db_file << ") is path name" << std::endl;
        if (std::regex_match(db_file, spe_name_reg))
        {
            std::cout << "db_file(" << db_file << ") is special path name" << std::endl;
            fullpath += projname_ + "_" + db_file;
        }
        else
        {
            fullpath += projname_ + "_" + NAME_SUFFIX + "_" + db_file;
        }
    }

    std::cout << "fullpath: " << fullpath << std::endl;
    printf("---------------end-----------------\n");
    return 0;
}